import Vue from 'vue'
import store from '@/store'
import VueI18n from 'vue-i18n'
import elEn from 'element-ui/lib/locale/lang/en'
import elZh from 'element-ui/lib/locale/lang/zh-CN'
import elTW from 'element-ui/lib/locale/lang/zh-TW'
import enUS from './en-US'
import zhCN from './zh-CN'
import zhTW from './zh-TW'
import {SettingsGetterEnum} from "@/store/enum/store.enum";

Vue.use(VueI18n)

const messages = {
	'en-US': {
		...enUS,
		...elEn,
	},
	'zh-CN': {
		...zhCN,
		...elZh,
	},
	'zh-TW': {
		...zhTW,
		...elTW,
	},
}

function getLanguage() {
  return store.getters[SettingsGetterEnum.language] || 'zh-CN'
}

const i18n = new VueI18n({
  locale: getLanguage(),
  messages,
})

export default i18n
